package com.song.ioc.循环依赖;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: TestMain：类描述
 * @author: songzhangyong
 * @Date: 2019/11/18 10:21
 */
public class TestMain {

	/**
	 * 模拟循环依赖，就是当a 在创建b的时候 ， 这时候b中依赖a ， 先去创建b，
	 * 然后再对b的a赋值正在创建a的值，这时候其实是内存地址，也就是下面的模拟情况
	 * @param args
	 */
	public static void main(String[] args) {
		User1 user1 = new User1();
		user1.age = "user1-age" ;
		user1.name = "user1-name" ;
		user1.sex = "user1-sex" ;

		User2 user2 = new User2();
		user2.age = "user2-age" ;
		user2.name = "user2-name" ;
		user2.sex = "user2-sex" ;
		user2.user1 = user1 ;
//		System.out.println(user2.user1.user2.user1.user2.user1.name);

		user1.user2 = user2 ;
		System.out.println(user2.user1.user2.user1.user2.user1.name);


		List<String> ss = new ArrayList<String>();
		ss.add("--1,--2,--3,--4,--5,--6,--7");
		ss = Arrays.asList(ss.get(0).replaceAll("--","").split(","));
		System.out.println(ss.size());

	}
}
